home *** CD-ROM | disk | FTP | other *** search
/ Commodore 64 Scene Diskmags Assortment / Commodore_CEE_Vol._1_Issue_05_1995_Jack_Vander_White_Disk_3_of_3_Side_B.d64 / ace tips 2 < prev    next >
Text File  |  2023-02-26  |  17KB  |  760 lines

  1. ACE Pictures
  2.  
  3. From: Craig Bruce
  4.  
  5. Michael Parson writes:
  6.  
  7. >Craig Bruce has mentioned that he might add the ability to print his .bm format pictures with the next release of ACE. I have used this format a  lot to view many megs worth of pictures and have been simply amazed with  the outcome. I use the pbm utilities available for UNIX, amiga, and VMS  to convert my gif images to xbm, then use Bruce's xbm to bm converter on  my unix host. The quality here is on par with geogif, just that you do  not have to load up geos to do the conversions, and on a 128 with 64k  VDC, you get a nice 640x480 display. ACE's vbm (the viewer) can also  handle larger images than 640x480 giving you the ability to scroll  through the image. Once again, if you can load the image off the REU, the scrolling is very nice =)
  8.  
  9. The deed is done. I hacked together an ACE utility program to print out VBM images to Epson-compatible dot-matrix printers last night. The program "vbmpr" in included below, in bcoded form. Its usage is as follows:
  10.  
  11. vbmpr [-help] filename ...
  12.  
  13. The indicated file will be printed, and if there are multiple files, they will be printed one directly after the other. All images are printed from the left margin, and the program uses the 640 dots-per-line graphic mode of the printer. This will produce an image that does not have a perfect aspect ratio (which would be 576 dpl), but I figured that it would be more important to be able to print 640xN images. The height of an image is, of course, limited only by the amount of paper that you have.
  14.  
  15. This program is separate from the "vbm" viewer program to make it easier to build. When run, the program will open a channel to your printer through device "q:" of your configuration. This device should be set up as a transparent-mode non-auto-linefeed connection to your printer/printer interface.
  16.  
  17. The source code is also included below, in case you want to make minor custom modifications to the program. The source is written for the ACE assembler. The code is a little messy, since it is just a quick hack.
  18.  
  19. I tested the speed of the program on a 640x480 image, and it took ten seconds to input the image from the ramdisk and output the printer data to the null device, so the bottleneck in the system will definitely be the speed of the connection to your printer or your printer itself, and not this printing program.
  20.  
  21. ;*** VBM Bitmap Printer 1.00 - by Craig Bruce - 08-Feb-1995
  22.  
  23. ;this file is in ACE-assembler format
  24.  
  25. ;vbmpr [-help] file ...
  26.  
  27. ;--->#include "acehead.s"
  28. ;===ace system interface declarations===
  29.  
  30. zp      = $f8  ;(2)
  31. zw      = $fa  ;(2)
  32. mp      = $fc  ;(4)
  33. syswork = $80  ;(16)
  34.  
  35. aceStatB         = $f00
  36. errno            = aceStatB+0          ;(1)
  37. aceID            = aceStatB+2          ;(2)
  38. aceArgc          = aceStatB+4          ;(2)
  39. aceArgv          = aceStatB+6          ;(2)
  40. aceMemTop        = aceStatB+8          ;(2)
  41. aceShellPath     = $c00                ;(256)
  42. aceShellAlias    = $d00                ;(256)
  43. aceCurDirName    = aceStatB+$80        ;(128)
  44. aceExitData      = $e00                ;(256)
  45. aceDirentBuffer  = aceStatB+10         ;(aceDirentLength)
  46. aceDirentBytes   = aceDirentBuffer+0   ;(4)
  47. aceDirentDate    = aceDirentBuffer+4   ;(8) = YY:YY:MM:DD:HH:MM:SS:TW
  48. aceDirentType    = aceDirentBuffer+12  ;(4)
  49. aceDirentFlags   = aceDirentBuffer+16  ;(1) = drwx*e-t
  50. aceDirentUsage   = aceDirentBuffer+17  ;(1) = ulshb---
  51. aceDirentNameLen = aceDirentBuffer+18  ;(1)
  52. aceDirentName    = aceDirentBuffer+19  ;(17)
  53. aceDirentLength  = 36
  54.  
  55. aceCallB  = $2803
  56. open      = aceCallB+0   ;( (zp)=Name, .A=Mode ) : .A=fd
  57. close     = aceCallB+3   ;( .A=fd )
  58. read      = aceCallB+6   ;( .X=fd, (zp)=Buf, .AY=Len ) : .AY=(zw)=Len, .Z
  59. write     = aceCallB+9   ;( .X=fd, (zp)=Buf, .AY=Len )
  60. fastopen  = aceCallB+12  ;( (zp)=Name, .A=Mode ) : .A=fd
  61. fastclose = aceCallB+15  ;( .A=fd )
  62. fastread  = aceCallB+18  ;( .X=fd, (zp)=Buf, .AY=Len ) : .AY=(zw)=Len, .Z
  63. bload     = aceCallB+21  ;( (zp)=Name, .AY=LoadAddr, (zw)=Limit+1 ) :
  64. .AY=End+1
  65. remove    = aceCallB+24  ;( (zp)=Name )
  66. rename    = aceCallB+27  ;( (zp)=OldName, (zw)=NewName )
  67. devinfo   = aceCallB+30  ;( .X=fd ) : .A=DevType, .X=Cols, .Y=Rows
  68. fdswap    = aceCallB+33  ;( .X=fd1, .Y=fd2 )
  69.  
  70. diropen   = aceCallB+36  ;( (zp)=DirName ) : .A=fd
  71. dirclose  = aceCallB+39  ;( .A=fd )
  72. dirread   = aceCallB+42  ;( .X=fd ) : direntBuffer, .Z=eof
  73. isdir     = aceCallB+45  ;( (zp)=Name ) : .A=Dev, .X=isDisk, .Y=isDir
  74. chdir     = aceCallB+48  ;( (zp)=DirName )
  75. cdhome    = aceCallB+51  ;( )
  76. mkdir     = aceCallB+54  ;( (zp)=NewDirName )
  77. rmdir     = aceCallB+57  ;( (zp)=DirName )
  78.  
  79. zpload    = aceCallB+60  ;( [mp]=Source, .X=ZpDest, .Y=Length )
  80. zpstore   = aceCallB+63  ;( .X=ZpSource, [mp]=Dest, .Y=Length )
  81. fetch     = aceCallB+66  ;( [mp]=FarSource, (zp)=Ram0Dest, .AY=Length )
  82. stash     = aceCallB+69  ;( (zp)=Ram0Source, [mp]=FarDest, .AY=length )
  83. pagealloc = aceCallB+72  ;( .A=PageCount, .X=StartTyp, .Y=EndTyp ) :
  84. [mp]=FarPtr
  85. pagefree  = aceCallB+75  ;( [mp]=FarPointer, .A=PageCount )
  86.  
  87. winmax    = aceCallB+78  ;( )
  88. wincls    = aceCallB+81  ;( .A=char/color/attrFlags, .X=char, .Y=color )
  89. winset    = aceCallB+84  ;( .A=rows, .X=cols, sw+0=scrRow, sw+1=scrCol )
  90. winsize   = aceCallB+87  ;( ) : <above>+ ,(sw+2)=addr,(sw+4)=rowinc
  91. winput    = aceCallB+90  ;( (sw+0)=addr,(sw+2)=charPtr,.A=attr,.Y=color,.X=len
  92.                             ;  sw+4=fillChar, sw+5=fieldLen )
  93. wincolor  = aceCallB+93  ;( .X=screen, .Y=border, .A=which ) : .X=scr, .Y=bor
  94. winpos    = aceCallB+96  ;( .A=row, .X=col ) : (sw+0)=addr
  95. wincursor = aceCallB+99  ;( (sw+0)=addr, .Y=color, .A=$ff:on/$00:off)
  96. winscroll = aceCallB+102 ;(
  97. .A=attr+$08:up+$04:down,.X=rows,sw+4=char,.Y=color)
  98.  
  99. conread   = aceCallB+105 ;( (zp)=Buf, .AY=Len ) : .AY=(zw)=Len, .Z
  100. conwrite  = aceCallB+108 ;( (zp)=Buf, .AY=Len )
  101. conputchar = aceCallB+111 ;( .A=char )
  102. conputlit = aceCallB+114 ;( .A=char )
  103. stopkey   = aceCallB+117 ;( ) : .CC=notPressed
  104. getkey    = aceCallB+120 ;( ) : .A=key
  105. concolor  = aceCallB+123 ;( .A=which, .X=char, .Y=cursor ) : .X=char,.Y=cursr
  106. conpalette = aceCallB+126 ;( ) : sw+0...sw+7=palette [8 colors]
  107. conscreen = aceCallB+129 ;( .A=MinRows, .X=MinCols )
  108. conpos    = aceCallB+132 ;( .A=row, .X=col )
  109.  
  110. exec      = aceCallB+135 ;( (zp)=execName, (zw)=argv, .AY=argCnt,
  111. [mp]=saveArea)
  112.                            ;  : .A=exitCode, .X=exitDataLen, [mp]=saveArea
  113. execsub   = aceCallB+138 ;( (zp)=execAddr, (zw)=argv, .AY=argCnt,
  114. [mp]=saveArea)
  115.                            ;  : .A=exitCode, .X=exitDataLen, [mp]=saveArea
  116. exit      = aceCallB+141 ;( .A=exitCode, .X=exitBufDataLen, exitData )
  117. memstat   = aceCallB+144 ;( ) : .A=procID, [sw+0]=total, [sw+4]=free
  118.  
  119. utoa      = aceCallB+147 ;( $0+X=value32, (sw+0)=buf, .A=minLen ) :buf, .Y=len
  120. getdate   = aceCallB+150 ;( (.AY)=dateString ) : dateString
  121. setdate   = aceCallB+153 ;( (.AY)=dateString )
  122. cmdopen   = aceCallB+156 ;( (zp)=DevName ) : .A=fd
  123. cmdclose  = aceCallB+159 ;( .A=fd )
  124. cmdsend   = aceCallB+162 ;( .X=fd, (.AY)=CmdString )
  125. cmdstatus = aceCallB+165 ;( .X=fd, (.AY)=StatBufPtr ) : StatBuf, .A=statusCode
  126. grscreen  = aceCallB+168 ;(...)...
  127. grexit    = aceCallB+171 ;(...)...
  128. grfill    = aceCallB+174 ;(...)...
  129. grload    = aceCallB+177 ;(...)...
  130. conkeyavail = aceCallB+180  ;( ) : .CC=keyIsAvailable
  131.  
  132. aceAppAddress = $7000
  133. aceID1 = $cb
  134. aceID2 = $06
  135. aceID3 = 11
  136.  
  137. aceMemNull = $00
  138. aceMemREU = $01
  139. aceMemInternal = $02
  140. aceMemRLREU = $06
  141. aceMemRL = $07
  142.  
  143. aceErrStopped = 0
  144. aceErrTooManyFiles = 1
  145. aceErrFileOpen = 2
  146. aceErrFileNotOpen = 3
  147. aceErrFileNotFound = 4
  148. aceErrDeviceNotPresent = 5
  149. aceErrFileNotInput = 6
  150. aceErrFileNotOutput = 7
  151. aceErrMissingFilename = 8
  152. aceErrIllegalDevice = 9
  153. aceErrWriteProtect = 26
  154. aceErrFileExists = 63
  155. aceErrFileTypeMismatch = 64
  156. aceErrNoChannel = 70
  157. aceErrDiskFull = 72
  158. aceErrInsufficientMemory = 128
  159. aceErrOpenDirectory = 129
  160. aceErrDiskOnlyOperation = 131
  161. aceErrNullPointer = 132
  162. aceErrInvalidFreeParms = 133
  163. aceErrFreeNotOwned = 134
  164. aceErrInvalidWindowParms = 135
  165. aceErrInvalidConParms = 136
  166. aceErrInvalidFileMode = 137
  167. aceErrNotImplemented = 138
  168. aceErrBloadTruncated = 139
  169. aceErrPermissionDenied = 140
  170. aceErrNoGraphicsSpace = 141
  171.  
  172. stdin  = 0
  173. stdout = 1
  174. stderr = 2
  175. ;===end of ace interface declarations===
  176.  
  177. org aceAppAddress
  178.  
  179. jmp main
  180. db aceID1,aceID2,aceID3
  181. db 64,0  ;** stack,reserved
  182.  
  183. ;*** global declarations
  184.  
  185. chrBEL = $07
  186. chrTAB = $09
  187. chrLF = $0a
  188. chrCR = $0d
  189. chrBS = $14
  190. chrCLR = $93
  191. chrQUOTE = $22
  192.  
  193. arg          =  2 ;(2)  ;current argument number
  194. name         =  4 ;(2)  ;name of file being kared
  195. inBufLen     =  6 ;(2)  ;total size of input buffer
  196. inFile       =  8 ;(1)  ;input file descriptor
  197. aspect       = 10 ;(1)  ;x
  198. bmCols       = 11 ;(1)  ;x
  199. bmRows       = 12 ;(2)  ;x
  200. topMargin    = 14 ;(2)  ;x
  201. leftMargin   = 16 ;(1)  ;x
  202. imageRows    = 18 ;(2)  ;x
  203. imageCols    = 20 ;(1)  ;x
  204. displayRow   = 22 ;(2)  ;x
  205. displayCol   = 24 ;(1)  ;x
  206. displayRows  = 26 ;(2)  ;x
  207. displayCols  = 28 ;(1)  ;x
  208. gotoNext     = 29 ;(1)  ;flag for skipping keypress after error
  209. printerFd    = 30 ;(1)  ;file descriptor for printer
  210. prgrFirst    = 31 ;(1)  ;first
  211. imageChopMask= 32 ;(1)  ;and of last column
  212. work         = 112 ;(16);temporary work area, lowest level
  213.  
  214. ;===main===
  215.  
  216. main = *
  217.    ;** check for a large enough TPA
  218.    sec
  219.    lda #<bssEnd
  220.    cmp aceMemTop+0
  221.    lda #>bssEnd
  222.    sbc aceMemTop+1
  223.    bcs +
  224.    jmp mainInit
  225. +  lda #<tpaMsg
  226.    ldy #>tpaMsg
  227.    jsr eputs
  228. die = *
  229.    lda #1
  230.    ldx #0
  231.    jmp exit
  232.  
  233. tpaMsg = *
  234.    db "Insufficient program space to run\n",0
  235.  
  236. usage = *
  237.    lda #<usageMsg
  238.    ldy #>usageMsg
  239.    jsr eputs
  240.    jmp die
  241.  
  242. usageMsg = *
  243.    db "usage: vbmpr [-help] file ...\n",0
  244.  
  245. mainInit = *
  246.    lda #1
  247.    ldy #0
  248.    jsr getarg
  249.    ldy #0
  250.    lda (zp),y
  251.    cmp #"-"
  252.    bne +
  253.    jmp usage
  254. +  lda #0
  255.    sta arg+0
  256.    sta arg+1
  257.    jsr startGraphics
  258.  
  259.    mainNext = *
  260.    jsr checkStop
  261.    inc arg+0
  262.    bne +
  263.    inc arg+1
  264. +  lda arg+0
  265.    ldy arg+1
  266.    jsr getarg
  267.    beq mainExit
  268.    lda zp+0
  269.    ldy zp+1
  270.    sta name+0
  271.    sty name+1
  272.    jsr vbmprint
  273.    jmp mainNext
  274.  
  275. mainExit = *
  276.    lda #<printerLineNorm
  277.    ldy #>printerLineNorm
  278.    ldx printerFd
  279.    jsr fputs
  280.    lda printerFd
  281.    jsr close
  282.    lda #chrCR
  283.    jsr putchar
  284.    rts
  285.    printerLineNorm : db 27,"2",0
  286.  
  287. startGraphics = *
  288.    lda #<printerFilename
  289.    ldy #>printerFilename
  290.    sta zp+0
  291.    sty zp+1
  292.    lda #"w"
  293.    jsr open
  294.    bcc +
  295.    lda #<printerFilenameErr
  296.    ldy #>printerFilenameErr
  297.    jsr eputs
  298.    jmp die
  299. +  sta printerFd
  300.    lda #<printerLinespace
  301.    ldy #>printerLinespace
  302.    ldx printerFd
  303.    jsr fputs
  304.    lda #80
  305.    ldx #1
  306.    sta bmCols
  307.    stx aspect
  308.    lda #255
  309.    ldy syswork+1
  310.    sta bmRows+0
  311.    sty bmRows+1
  312.    rts
  313.  
  314.    printerFilename : db "q:",0
  315.    printerFilenameErr : db 'Cannot open "q:" file\n',0
  316.    printerLinespace : db 27,"a",8,0
  317.  
  318. checkStop = *
  319.    jsr stopkey
  320.    bcs +
  321.    rts
  322. +  lda #<stoppedMsg
  323.    ldy #>stoppedMsg
  324.    jsr eputs
  325.    jmp die
  326.    stoppedMsg : db "<Stopped>\n",0
  327.  
  328. vbmprint = *
  329.    lda #0
  330.    sta topMargin+0
  331.    sta topMargin+1
  332.    sta leftMargin
  333.  
  334.    ;** open file
  335.    lda name+0
  336.    ldy name+1
  337.    sta zp+0
  338.    sty zp+1
  339.    lda #"r"
  340.    jsr open
  341.    bcc +
  342.    jsr echoName
  343.    lda #<openErrMsg
  344.    ldy #>openErrMsg
  345.    jsr eputs
  346.    rts
  347. +  sta inFile
  348.    ;** check and extract header information
  349.    lda #8
  350.    jsr binRead
  351.    bcs invalidFormat
  352.    lda inBuf+0
  353.    cmp #"b"
  354.    bne invalidFormat
  355.    lda inBuf+1
  356.    cmp #"m"
  357.    bne invalidFormat
  358.    lda inBuf+2
  359.    cmp #$cb
  360.    bne invalidFormat
  361.    lda inBuf+3
  362.    cmp #2
  363.    bne invalidFormat
  364.    lda inBuf+5
  365.    and #$07
  366.    tax
  367.    lda imageChopMasks,x
  368.    sta imageChopMask
  369.    ldy inBuf+4  ;hi/lo
  370.    lda inBuf+5
  371.    clc
  372.    adc #7
  373.    bcc +
  374.    iny
  375. +  sty work
  376.    lsr work
  377.    ror
  378.    lsr work
  379.    ror
  380.    lsr work
  381.    ror
  382.    sta imageCols
  383.    ldy inBuf+6  ;hi/lo
  384.    lda inBuf+7
  385.    sta imageRows+0
  386.    sty imageRows+1
  387.    ;** display
  388.    jsr viewBody
  389.    ;** close
  390.    lda inFile
  391.    jsr close
  392.    rts
  393.    imageChopMasks : db %11111111,%10000000,%11000000,%11100000
  394.                     db %11110000,%11111000,%11111100,%11111110
  395.  
  396.    invalidFormat = *
  397.    jsr echoName
  398.    lda #<invalidFormatMsg
  399.    ldy #>invalidFormatMsg
  400.    jsr eputs
  401.    rts
  402.    invalidFormatMsg : db ": invalid VBM format\n",0
  403.    openErrMsg : db ": cannot open\n",0
  404.  
  405. echoName = *
  406.    lda name+0
  407.    ldy name+1
  408.    jsr eputs
  409.    rts
  410.  
  411. binReadLen : buf 1
  412.  
  413. binRead = *  ;( .A=bytes, inFile )
  414.    sta binReadLen
  415.    lda #<inBuf
  416.    ldy #>inBuf
  417.    sta zp+0
  418.    sty zp+1
  419.    ldx inFile
  420.    lda binReadLen
  421.    ldy #0
  422.    jsr read
  423.    beq +
  424.    bcs +
  425.    cmp binReadLen
  426.    bne +
  427.    clc
  428.    rts
  429. +  sec
  430.    rts
  431.  
  432. viewBody = *  ;( no pun intended... )
  433.    ;** set default display margins
  434.    lda #0
  435.    sta displayRow+0
  436.    sta displayRow+1
  437.    sta displayCol
  438.  
  439.    fiddleCols = *
  440.    lda bmCols
  441.    cmp imageCols
  442.    bcc +
  443.    lda #0
  444.    sta leftMargin
  445.    lda imageCols
  446.    sta displayCols
  447.    jmp fiddleRows
  448. +  lda bmCols
  449.    sta displayCols
  450.    lda #0
  451.    sta leftMargin
  452.  
  453.    fiddleRows = *
  454.    lda #0
  455.    sta topMargin+0
  456.    sta topMargin+1
  457.    lda imageRows+0
  458.    ldy imageRows+1
  459.    sta displayRows+0
  460.    sty displayRows+1
  461.  
  462.    ;** skip top margin
  463.    lda topMargin+0
  464.    ldy topMargin+1
  465.    ldx imageCols
  466.    jsr skipPixelLines
  467.  
  468.    jsr prgrInit
  469.  
  470.    ;** display main portion of image
  471.    viewNextLine = *
  472.    jsr checkStop
  473.    lda displayRows+0
  474.    ora displayRows+1
  475.    bne +
  476.    jsr prgrFlush
  477.    rts
  478. +  ldx leftMargin
  479.    sec
  480.    lda imageCols
  481.    sbc leftMargin
  482.    sec
  483.    sbc displayCols
  484.    tay
  485.    lda displayCols
  486.    jsr readPixelLine
  487.    lda displayRow+0
  488.    ldy displayRow+1
  489.    sta syswork+0
  490.    sty syswork+1
  491.    lda #<pixelBuf
  492.    ldy #>pixelBuf
  493.    sta syswork+2
  494.    sty syswork+3
  495.    lda displayCol
  496.    ldx displayCols
  497.    ldy #1
  498.    jsr prgrLoad
  499.    inc displayRow+0
  500.    bne +
  501.    inc displayRow+1
  502. +  lda displayRows+0
  503.    bne +
  504.    dec displayRows+1
  505. +  dec displayRows+0
  506.    jmp viewNextLine
  507.  
  508. skipCount : buf 2
  509. skipBytes : buf 1
  510.  
  511. skipPixelLines = * ;( .AY=lines, .X=lineLen )
  512.    sta skipCount+0
  513.    sty skipCount+1
  514.    stx skipBytes
  515. -  lda skipCount+0
  516.    ora skipCount+1
  517.    bne +
  518.    rts
  519. +  lda skipBytes
  520.    jsr binRead
  521.    lda skipCount+0
  522.    bne +
  523.    dec skipCount+1
  524. +  dec skipCount+0
  525.    jmp -
  526.  
  527. skipLeft  : buf 1
  528. payDirt   : buf 1
  529. skipRight : buf 1
  530.  
  531. readPixelLine = * ;( .X=leftSkip, .A=payDirt, .Y=rightSkip ) : pixelBuf
  532.    stx skipLeft
  533.    sta payDirt
  534.    sty skipRight
  535.    lda skipLeft
  536.    beq +
  537.    jsr binRead
  538. +  lda payDirt
  539.    beq +
  540.    jsr binRead
  541.    ldx payDirt
  542.    dex
  543. -  lda inBuf,x
  544.    sta pixelBuf,x
  545.    dex
  546.    bpl -
  547. +  lda skipRight
  548.    beq +
  549.    jsr binRead
  550. +  rts
  551.  
  552. prgrInit = *
  553.    lda #$ff
  554.    sta prgrFirst
  555.    jsr prgrFill
  556.    rts
  557.  
  558. prgrFill = *
  559.    ldx #0
  560.    lda #$00
  561. -  sta prbitmap+$000,x
  562.    sta prbitmap+$100,x
  563.    sta prbitmap+$200,x
  564.    sta prbitmap+$300,x
  565.    sta prbitmap+$400,x
  566.    sta prbitmap+$500,x
  567.    sta prbitmap+$600,x
  568.    sta prbitmap+$700,x
  569.    inx
  570.    bne -
  571.    rts
  572.  
  573. prCols = work-1
  574. prDataPtr = work-3
  575.  
  576. prgrLoad = *  ;( .A=X, (sw+0)=Y, .X=cols, .Y=1, (sw+2)=ptr )
  577.    stx prCols
  578.    lda syswork+2
  579.    ldy syswork+3
  580.    sta prDataPtr+0
  581.    sty prDataPtr+1
  582.    bit prgrFirst
  583.    bmi +
  584.    lda syswork+0
  585.    and #$07
  586.    bne +
  587.    jsr prgrFlush
  588.    jsr prgrFill
  589. +  lda #0
  590.    sta prgrFirst
  591.    lda syswork+0
  592.    and #$07
  593.    clc
  594.    adc #>prbitmap
  595.    ldx #<prbitmap
  596.    stx work+0
  597.    sta work+1
  598.    ldy #0
  599. -  lda (prDataPtr),y
  600.    sta (work+0),y
  601.    iny
  602.    cpy prCols
  603.    bcc -
  604.    dey
  605.    lda (work+0),y
  606.    and imageChopMask
  607.    sta (work+0),y
  608.    lda #"l"
  609.    jsr putchar
  610.    rts
  611.  
  612. flOff = work+2 ;(1)
  613. flBit = work+3 ;(1)
  614. flNcols = work+4 ;(2)
  615.  
  616. prgrFlush = *
  617.    lda #"f"
  618.    jsr putchar
  619.    lda #0
  620.    sta flOff
  621.    lda #27
  622.    ldx printerFd
  623.    jsr putc
  624.    lda #"*"
  625.    ldx printerFd
  626.    jsr putc
  627.    lda #4     ;graphics mode%%%
  628.    ldx printerFd
  629.    jsr putc
  630.    lda displayCols
  631.    ldy #$00
  632.    sty flNcols+1
  633.    asl
  634.    rol flNcols+1
  635.    asl
  636.    rol flNcols+1
  637.    asl
  638.    rol flNcols+1
  639.    ldx printerFd
  640.    jsr putc  ;low byte
  641.    lda flNcols+1
  642.    ldx printerFd
  643.    jsr putc  ;high byte
  644. -  lda #$80
  645.    sta flBit
  646. -  jsr flushBitcol
  647.    lsr flBit
  648.    bcc -
  649.    inc flOff
  650.    lda flOff
  651.    cmp displayCols
  652.    bcc --
  653.    lda #13
  654.    ldx printerFd
  655.    jsr putc
  656.    lda #10
  657.    ldx printerFd
  658.    jsr putc
  659.    rts
  660.  
  661. flPtr    = work+6 ;(2)
  662. flByte   = work+8 ;(1)
  663. flRow    = work+9 ;(1)
  664.  
  665. flushBitcol = *  ;( flOff, flBit )
  666.    ;** init
  667.    lda #$00
  668.    sta flByte
  669.    sta flRow
  670.    lda #<prbitmap
  671.    ldy #>prbitmap
  672.    sta flPtr+0
  673.    sty flPtr+1
  674.    ;** work
  675. -  ldy flOff
  676.    lda (flPtr),y
  677.    and flBit
  678.    cmp #0+1
  679.    rol flByte
  680.    ;** next
  681.    inc flPtr+1
  682.    inc flRow
  683.    lda flRow
  684.    cmp #8
  685.    bcc -
  686.    ;** finish
  687.    lda flByte
  688.    ldx printerFd
  689.    jsr putc
  690.    rts
  691.  
  692. ;=== standard library ===
  693.  
  694. puts = *
  695.    ldx #stdout
  696. fputs = *
  697.    sta zp+0
  698.    sty zp+1
  699.    ldy #$ff
  700. -  iny
  701.    lda (zp),y
  702.    bne -
  703.    tya
  704.    ldy #0
  705.    jmp write
  706. eputs = *
  707.    ldx #stderr
  708.    jmp fputs
  709.  
  710. eputchar = *
  711.    ldx #stderr
  712.    jmp putc
  713. putchar = *
  714.    ldx #stdout
  715. putc = *
  716.    sta putcBuffer
  717.    lda #<putcBuffer
  718.    ldy #>putcBuffer
  719.    sta zp+0
  720.    sty zp+1
  721.    lda #1
  722.    ldy #0
  723.    jmp write
  724.    putcBuffer : buf 1
  725.  
  726. getarg = *
  727.    sty zp+1
  728.    asl
  729.    sta zp+0
  730.    rol zp+1
  731.    clc
  732.    lda aceArgv+0
  733.    adc zp+0
  734.    sta zp+0
  735.    lda aceArgv+1
  736.    adc zp+1
  737.    sta zp+1
  738.    ldy #0
  739.    lda (zp),y
  740.    tax
  741.    iny
  742.    lda (zp),y
  743.    stx zp+0
  744.    sta zp+1
  745.    ora zp+0
  746.    rts
  747.  
  748. ;===bss===
  749.  
  750. bss      = *
  751. pixelBuf = bss
  752. inBuf    = pixelBuf+256
  753. prbitmap = inBuf+256
  754. bssEnd   = prbitmap+2048   ;256*8
  755. -----=-----
  756. --------------------------------
  757.  
  758.  
  759.  
  760.